package com.demo.config.datasource.annotation;


/**
 * @author wangfengchen
 */
public class DynamicDataSourceContextHolder {
  private static final ThreadLocal<String> CONTEXT = new ThreadLocal<>();

  // 设置当前数据源
  public static void setDataSourceKey(String key) {
    CONTEXT.set(key);
  }

  // 获取当前数据源
  public static String getDataSourceKey() {
    return CONTEXT.get();
  }

  // 清除数据源（防止内存泄漏）
  public static void clearDataSourceKey() {
    CONTEXT.remove();
  }


}